﻿using DataBase.Utils;
using Prism.Mvvm;
using System;
using System.Collections.Generic;

namespace GreenXi.Model
{
    public class BackupInfo : BindableBase
    {
        /// <summary>
        /// 备份文件名称
        /// </summary>
        public string FileName { get; set; } = "";

        /// <summary>
        /// 备份文件的大小
        /// </summary>
        public string FileSize { get; set; } = "";

        /// <summary>
        /// 备份的时间
        /// </summary>
        public string BackupTime { get; set; } = "";

        //备份间隔天数
        private int _backupIntervalDay;

        public int BackupIntervalDay
        {
            get
            {
                return _backupIntervalDay;
            }
            set
            {
                value = value > 31 ? 31 : value;
                value = value < 1 ? 1 : value;
                SetProperty(ref _backupIntervalDay, value);
                MyDbContext.SetSettingDbInfo("BackupIntervalDay", _backupIntervalDay);
            }
        }

        //备份间隔时间
        private TimeSpan _backupIntervalTime;

        public TimeSpan BackupIntervalTime
        {
            get
            {
                return _backupIntervalTime;
            }
            set
            {
                SetProperty(ref _backupIntervalTime, value);
                MyDbContext.SetSettingDbInfo("BackupIntervalTime", _backupIntervalTime);
            }
        }

        //当前备份路径
        private string _currentFolderPath;

        public string CurrentFolderPath
        {
            get { return _currentFolderPath; }
            set { SetProperty(ref _currentFolderPath, value); }
        }

        //当前备份名称
        private string _currentFileName;

        public string CurrentFileName
        {
            get { return _currentFileName; }
            set { SetProperty(ref _currentFileName, value); }
        }

        //当前还原路径
        private string _currentReductionPath;

        public string CurrentReductionPath
        {
            get { return _currentReductionPath; }
            set { SetProperty(ref _currentReductionPath, value); }
        }

        //表格内容
        private List<BackupInfo> _backupInfoList;

        public List<BackupInfo> BackupInfoList
        {
            get { return _backupInfoList; }
            set { SetProperty(ref _backupInfoList, value); }
        }

        //当前选择的内容
        private BackupInfo? _selectBackupInfo;
        public BackupInfo? SelectBackupInfo
        {
            get { return _selectBackupInfo; }
            set { SetProperty(ref _selectBackupInfo, value); }
        }
    }
}
